package com.bysj.lms.service.impl;

import com.bysj.lms.pojo.entity.RoleUser;
import com.bysj.lms.mapper.RoleUserMapper;
import com.bysj.lms.service.IRoleUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaojiakai
 * @since 2022-02-04
 */
@Service
public class RoleUserServiceImpl extends ServiceImpl<RoleUserMapper, RoleUser> implements IRoleUserService {

    @Autowired
    RoleUserMapper roleUserMapper;

    @Override
    public boolean adds(List<Integer> roleIds, String uid) {
        int adds = roleUserMapper.adds(roleIds, uid);
        return adds!=0?true:false;
    }

    @Override
    public boolean removes(List<Integer> roleIds, String uid) {
        int removes = roleUserMapper.remove(roleIds, uid);
        return removes!=0?true:false;
    }

    @Override
    public boolean edit(List<Integer> roleIds, String uid) {
        return removes(null,uid) && adds(roleIds, uid);
    }

//    @Autowired
//    IRoleService roleService;
//    @Autowired
//    RoleUserMapper roleUserMapper;
//
//    @Override
//    public List<RoleUser> getByUsername(String userId) {
//        LambdaQueryWrapper<RoleUser> query = Wrappers.lambdaQuery(RoleUser.class).eq(RoleUser::getUserId,userId);
//        List<RoleUser> roleUsers = roleUserMapper.selectList(query);
//        return roleUsers;
//    }
}
